import React, { Component } from 'react'
import {Layout,Menu,Dropdown,Icon} from 'antd';
import {Link} from 'dva/router';
import styles from './index.less';
import { connect } from 'dva';
const {Header} = Layout;
export default 
@connect(state=>state.login) 
class componentName extends Component {
  componentWillMount(){
    this.props.dispatch({
      type:'login/loadUserFromLocal'
    });
  }
  getMenus = ()=>(
      <Menu>
        <Menu.Item>
          <Link to="/login">退出</Link>
        </Menu.Item>
      </Menu>
  )
  render() {
    let userInfo = this.props.userInfo;
    return (
    <Header>
        <img className={styles.logo}  src="http://img.zhufengpeixun.cn/zfpxlogo.png"/>
        {
           userInfo&&(
            <Dropdown className={styles.welcome} overlay={this.getMenus()}>
                      <a className="ant-dropdown-link" href="#">
                        <span >欢迎 {userInfo.username}</span> <Icon type="down" />
                      </a>
            </Dropdown>
           )
        }
         
      </Header>
    )
  }
}
